#+AUTHOR:Joshua Branson
#+LATEX_HEADER: \usepackage{lmodern}
#+LATEX_HEADER: \usepackage[QX]{fontenc}

* lexical binding
  :PROPERTIES:
  :ID:       c901c3d8-a46e-4b21-9105-482ab7b8ef16
  :END:

#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding: t; -*-
#+END_SRC

* check-network-connection
  :PROPERTIES:
  :ID:       244b5234-cee7-4d5c-9e1a-47d5c2a85741
  :END:

I am starting a synchronous process to determine if I have an internet
connection.  If I do have an internet connection, then the global
variable my-onlinep will be t.

#+BEGIN_SRC emacs-lisp
  (setq my-onlinep nil)

  (defun my/nmcli-filter-function (proc output)
    (cond
     ((string= output "full\n")
      (setq my-onlinep t))
     ((or (string= output "none\n")
          (string= output "unknown\n"))
      (setq my-onlinep nil))))

  (defun my/check-internet-connection ()
    (set-process-filter
     (start-process "nmcli" nil "nmcli" "-c" "no" "network" "connectivity"
                    "check")
     'my/nmcli-filter-function))

  (my/check-internet-connection)

#+END_SRC


** provide this file
   :PROPERTIES:
   :ID:       de7b8959-ad8a-488c-9b56-356ddb8ce264
   :END:
#+BEGIN_SRC emacs-lisp
(provide 'init-check-network-connection)
#+END_SRC
